package com.yugao.fintech.antelope.base.model.module.mq;

import lombok.*;

/**
 * 资源模块 eg: sys:dict:query 这是一个操作标识(action), 其中第一段 sys 就是资模块标识

 */
public class ResourceModuleRefreshMQ extends AbstractMQ {
    /**
     * 将服务模块注册到网关
     */
    public static final String QUEUE = "module";
    /**
     * 资源模块注册, 由gateway监听
     */
    public static final String KEY = "register_to_gateway";
    /**
     * 通知刷新
     */
    public static final String KEY_NOTICE = "notice_refresh";
    public static final String EXCHANGE = "resource_access_manager";


    public ResourceModuleRefreshMQ(MsgPayload msgPayload) {
        super(msgPayload);
    }

    @Data
    @Builder
    @EqualsAndHashCode(callSuper = true)
    @AllArgsConstructor
    @NoArgsConstructor
    public static class MsgPayload extends BaseMqPayload {
        /**
         * 模块编码(一般为名称首字母即可)
         */
        private String moduleCode;

        /**
         * 服务标识符, 这里指的是服务url的一级路径, 在网关配置文件中
         */
        private String serviceCode;

        public String toMessage() {
            return new ResourceModuleRefreshMQ(this).toMessage();
        }
    }



    public static MsgPayload.MsgPayloadBuilder builder(){
        MsgPayload.MsgPayloadBuilder builder = MsgPayload.builder();
        return builder;
    }
}
